<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<ui:composition template="template.xhtml">
	<ui:define name="content">
		<h:form id="form01">
			<p:panel header="Doctor List" style="text-align:center"
				rendered="#{mainMenuControler.hasUserRole('admin')}">
				<div style="float: left">
					<p:commandButton
						value="#{dictionaryControler.dictionary['Add']} #{dictionaryControler.dictionary['Doctor']}"
						actionListener="#{doctorMeintenanceControler.startAdd}"
						icon="ui-icon-plus" update=":form04:detailDialog" />
				</div>
				<br />
				<br />
				<br />
				<p:dataTable id="doctorTable" widgetVar="widgetVar_w"
					value="#{doctorMeintenanceControler.doctorList}" var="doctor"
					selectionMode="single"
					filteredValue="#{doctorMeintenanceControler.filteredTerms}"
					selection="#{doctorMeintenanceControler.selectedDoctor}" rows="15"
					paginator="true" paginatorAlwaysVisible="true"
					paginatorPosition="bottom"
					first="#{doctorMeintenanceControler.first}"
					paginatorTemplate="{PreviousPageLink} {CurrentPageReport} {NextPageLink}">
					<p:ajax event="rowSelect" oncomplete="PF('detailDialog_w').show()"
						update=":form04:detailDialog" />
					<p:column style="width:10%" filterBy="#{doctor.seq}"
						filterMatchMode="contains"
						headerText="#{dictionaryControler.dictionary['Seq']}">
						<h:outputText value="#{doctor.seq}" />
					</p:column>
					<p:column style="width:10%" filterBy="#{doctor.id}"
						filterMatchMode="contains"
						headerText="#{dictionaryControler.dictionary['ID']}">
						<h:outputText value="#{doctor.id}" />
					</p:column>
					<p:column style="width:15%" filterBy="#{doctor.name}"
						filterMatchMode="contains"
						headerText="#{dictionaryControler.dictionary['Name']}">
						<h:outputText value="#{doctor.name}" />
					</p:column>
					<p:column style="width:15%" filterBy="#{doctor.departmentDto}" filterMatchMode="exact"
						headerText="#{dictionaryControler.dictionary['Department']}">
						<f:facet name="filter">
							<p:selectOneMenu onchange="PF('widgetVar_w').filter()">
								<f:selectItem itemLabel="Select One" itemValue="#{null}"
									noSelectionOption="true" />
								<f:selectItems value="#{departmentListControler.baseDepartmentList}" var="department"
								itemLabel="#{department.name}" itemValue="#{department}"/>
							</p:selectOneMenu>
						</f:facet>
						<h:outputText value="#{doctor.departmentName}" />
					</p:column>
					<p:column style="width:30%"
						headerText="#{dictionaryControler.dictionary['Introduction']}">
						<h:outputText value="#{doctor.introduction}" />
					</p:column>
				</p:dataTable>
				<br />
			</p:panel>
			<h:outputText value="Access Denied, please contact the administrator"
				rendered="#{!mainMenuControler.hasUserRole('admin')}"
				style="width:100%; height:50%; text-align:center; font-size:150% !important;position:absolute; margin-left:0; margin-right:0; margin-top:0;margin-bottom:0" />
		</h:form>

	</ui:define>

	<ui:define name="dialog">

		<h:form id="form04">
			<p:dialog id="detailDialog" closable="false" modal="true"
				visible="#{doctorMeintenanceControler.editMode or doctorMeintenanceControler.addMode}"
				widgetVar="detailDialog_w" resizable="false" showEffect="fade"
				draggable="true"
				header="#{dictionaryControler.dictionary['Doctor Detail']}">
				<p:focus context="detailDialog" for="okBtn" />
				<p:panelGrid columns="2">

					<h:outputText value="#{dictionaryControler.dictionary['ID']}" />
					<h:outputText
						value="#{doctorMeintenanceControler.selectedDoctor.id}"
						rendered="#{doctorMeintenanceControler.browseMode or doctorMeintenanceControler.editMode}" />
					<p:inputText value="#{doctorMeintenanceControler.editDoctor.id}"
						rendered="#{doctorMeintenanceControler.addMode}" required="true"
						size="20" maxlength="20"
						requiredMessage="#{dictionaryControler.dictionary['ID']} #{dictionaryControler.dictionary['Required']}" />

					<h:outputText value="#{dictionaryControler.dictionary['Name']}" />
					<h:outputText
						value="#{doctorMeintenanceControler.selectedDoctor.name}"
						rendered="#{doctorMeintenanceControler.browseMode}" />
					<p:inputText value="#{doctorMeintenanceControler.editDoctor.name}"
						rendered="#{doctorMeintenanceControler.addMode or doctorMeintenanceControler.editMode}"
						required="true" size="20" maxlength="20"
						requiredMessage="#{dictionaryControler.dictionary['Name']} #{dictionaryControler.dictionary['Required']}" />

					<h:outputText value="#{dictionaryControler.dictionary['Gender']}" />
					<h:outputText
						value="#{dictionaryControler.dictionary[doctorMeintenanceControler.selectedDoctor.genderName]}"
						rendered="#{doctorMeintenanceControler.browseMode}" />
					<p:selectOneMenu id="genderCombo"
						value="#{doctorMeintenanceControler.editDoctor.gender}"
						rendered="#{doctorMeintenanceControler.addMode or doctorMeintenanceControler.editMode}"
						editable="false" style="width:98%">
						<f:selectItems value="#{genderListControler.genderList}"
							var="gender" itemLabel="#{gender.label}"
							itemValue="#{gender.value}" />
					</p:selectOneMenu>

					<h:outputText
						value="#{dictionaryControler.dictionary['Department']}" />
					<h:outputText
						value="#{doctorMeintenanceControler.selectedDoctor.departmentDto.name}"
						rendered="#{doctorMeintenanceControler.browseMode}" />
					<p:selectOneMenu
						value="#{doctorMeintenanceControler.editDoctor.departmentDtoSeq}"
						rendered="#{doctorMeintenanceControler.addMode or doctorMeintenanceControler.editMode}"
						style="width:98%">
						<f:selectItems
							value="#{doctorMeintenanceControler.departmentList}"
							var="department" itemLabel="#{department.name}"
							itemValue="#{department.seq}" />
					</p:selectOneMenu>

					<h:outputText value="#{dictionaryControler.dictionary['Password']}"
						rendered="#{doctorMeintenanceControler.addMode or doctorMeintenanceControler.editMode}" />
					<p:commandButton value="Password Edit"
						rendered="#{doctorMeintenanceControler.addMode or doctorMeintenanceControler.editMode}"
						actionListener="#{doctorMeintenanceControler.startPasswordEdit}"
						immediate="true" update=":form05:passwordDialog" />

					<h:outputText
						value="#{dictionaryControler.dictionary['Introduction']}" />
					<h:outputText
						value="#{doctorMeintenanceControler.selectedDoctor.introduction}"
						rendered="#{doctorMeintenanceControler.browseMode}" />
					<p:inputTextarea rows="5" cols="23"
						value="#{doctorMeintenanceControler.editDoctor.introduction}"
						rendered="#{doctorMeintenanceControler.addMode or doctorMeintenanceControler.editMode}"
						required="true" size="20" maxlength="200"
						requiredMessage="#{dictionaryControler.dictionary['Introduction']} #{dictionaryControler.dictionary['Required']}" />
				</p:panelGrid>
				<br />
				<p:dataTable id="doctorRoleTable" style="width:250px"
					value="#{doctorMeintenanceControler.selectedDoctor.roleList}"
					var="doctorRole"
					rendered="#{doctorMeintenanceControler.browseMode}">
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{dictionaryControler.dictionary['Role']}" />
						</f:facet>
						<h:outputText value="#{doctorRole.role}" />
					</p:column>
				</p:dataTable>
				<p:dataTable id="doctorRoleTableEdit" style="width:250px"
					value="#{doctorMeintenanceControler.roleListModel}"
					var="doctorRole"
					rendered="#{doctorMeintenanceControler.editMode or doctorMeintenanceControler.addMode}"
					selection="#{doctorMeintenanceControler.roleSelection}">
					<p:column selectionMode="multiple" style="width:28px" />
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{dictionaryControler.dictionary['Role']}" />
						</f:facet>
						<h:outputText value="#{doctorRole.role}" />
					</p:column>
				</p:dataTable>
				<br />
				<div style="text-align: right">
					<p:commandButton id="okBtn"
						value="#{dictionaryControler.dictionary['OK']}" ajax="true"
						onclick="detailDialog_w.hide();"
						rendered="#{doctorMeintenanceControler.browseMode}" />
					<p:commandButton id="startEditBtn"
						value="#{dictionaryControler.dictionary['Edit']}" ajax="true"
						update=":form04:detailDialog"
						actionListener="#{doctorMeintenanceControler.startEdit}"
						rendered="#{doctorMeintenanceControler.browseMode}" />
					<p:commandButton id="DeleteBtn"
						value="#{dictionaryControler.dictionary['Delete']}"
						oncomplete="PF('widgetVar_w').clearFilters();"
						update=":form01:doctorTable,:form04:detailDialog"
						actionListener="#{doctorMeintenanceControler.deleteDoctor}"
						rendered="#{doctorMeintenanceControler.browseMode}">
						<p:confirm
							header="#{dictionaryControler.dictionary['Confirmation']}"
							message="#{dictionaryControler.dictionary['Are you sure']}?"
							icon="ui-icon-alert" />
					</p:commandButton>
					<p:commandButton id="applyBtn"
						value="#{dictionaryControler.dictionary['Apply']}" ajax="true"
						rendered="#{!doctorMeintenanceControler.browseMode}"
						oncomplete="PF('widgetVar_w').clearFilters();"
						actionListener="#{doctorMeintenanceControler.apply}"
						update=":form01:doctorTable,:form04:detailDialog" />
					<p:commandButton id="discardBtn"
						value="#{dictionaryControler.dictionary['Discard']}" ajax="true"
						actionListener="#{doctorMeintenanceControler.discard}"
						rendered="#{!doctorMeintenanceControler.browseMode}"
						immediate="true" update=":form04:detailDialog"
						onclick="detailDialog_w.hide()" />
				</div>
				<p:messages />
			</p:dialog>
		</h:form>
		<h:form id="form05">
			<p:dialog id="passwordDialog" widgetVar="passwordDialog_w"
				modal="true" closable="false" resizable="false" draggable="true"
				header="#{dictionaryControler.dictionary['Password Setting']}"
				visible="#{doctorMeintenanceControler.passwordEdit}">
				<h:outputText
					value="#{dictionaryControler.dictionary['Enter Password']}" />

				<p:panelGrid columns="2">
					<h:outputText value="#{dictionaryControler.dictionary['Password']}" />
					<p:password value="#{doctorMeintenanceControler.password}"
						rendered="#{doctorMeintenanceControler.passwordEdit}"
						required="true"
						requiredMessage="#{dictionaryControler.dictionary['Password']} #{dictionaryControler.dictionary['Required']}" />
					<h:outputText
						value="#{dictionaryControler.dictionary['PasswordConfirm']}" />
					<p:password value="#{doctorMeintenanceControler.passwordConfirm}"
						rendered="#{doctorMeintenanceControler.passwordEdit}"
						required="true"
						requiredMessage="#{dictionaryControler.dictionary['PasswordConfirm']} #{dictionaryControler.dictionary['Required']}" />
				</p:panelGrid>

				<p:messages />

				<br />
				<div style="text-align: right">
					<p:commandButton value="#{dictionaryControler.dictionary['OK']}"
						actionListener="#{doctorMeintenanceControler.applyPassword}"
						update=":form05:passwordDialog"
						rendered="#{doctorMeintenanceControler.passwordEdit}" />
					<p:commandButton
						value="#{dictionaryControler.dictionary['Cancel']}"
						immediate="true"
						actionListener="#{doctorMeintenanceControler.discardPassword}"
						update=":form05:passwordDialog"
						rendered="#{doctorMeintenanceControler.passwordEdit}" />
				</div>


			</p:dialog>
		</h:form>
	</ui:define>
</ui:composition>
</html>